package com.example.tiku05.adapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.example.tiku05.bean.ProjectTypeBean;

import java.util.ArrayList;
import java.util.List;

public class VpFragmentAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> fragments;
    private List<ProjectTypeBean.DataBean> types;

    public VpFragmentAdapter(FragmentManager fm, ArrayList<Fragment> fs, List<ProjectTypeBean.DataBean> types) {
        super(fm);
        this.fragments = fs;
        this.types = types;
    }

    @Override
    public Fragment getItem(int i) {
        return fragments.get(i);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    /**
     * 为结合的tablayout配置tab页
     *
     * @param position
     * @return
     */
    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return types.get(position).getName();
    }
}
